package com.itheima.job.test03;

import java.io.IOException;
import java.net.*;

public class UDPSender {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket(12345);

        byte[] bytes = "服务端你好啊！".getBytes();
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length,InetAddress.getByName("127.0.0.1"),8888);
        ds.send(dp);


        DatagramPacket dp1 = new DatagramPacket(new byte[1024],1024);
        ds.receive(dp1);
        System.out.println(new String(dp1.getData(),0,dp1.getLength()));
        ds.close();

    }
}
